package cn.yunyichina.provider.pay.freestyle;

import org.junit.Test;

import java.util.UUID;

/**
 * Created by Lullaby on 2016/11/3.
 */
public class EnumSQLGenerator {

    @Test
    public void generate() {
        String prefix = "INSERT INTO `yyt_platform`.`sys_dictionary` (`ID`, `DIC_CODE`, `DIC_VALUE`, `DIC_DESC`, `PARENT_ID`, `ORDER_VALUE`, `REMARK`) VALUES ";

        StringBuilder builder = new StringBuilder();
        String dicCode = "TRADE_TYPE";
        String dicDesc = "支付商支付类型";

        String parentId = null;

        int length = 4;
        for (int i = 0; i < length; i++) {
            String id = this.getUUID();
            builder.append(prefix).append("('").append(id).append("','").
                    append(dicCode).append("',").append(i).append(",'").
                    append(dicDesc).append("',");
            if (i == 0) {
                parentId = id;
                builder.append("0,");
            } else {
                builder.append("'").append(parentId).append("',");
            }
            builder.append(i).append(",'").append(dicDesc).append("');");
            System.out.println(builder.toString());
            builder.setLength(0);
        }
    }

    private String getUUID() {
        return UUID.randomUUID().toString().replace("-", "");
    }

}
